home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / GrayImage 2.1 / gray image 2.1 / fractal_map.h < prev    next >
Encoding:
Text File  |  1995-05-03  |  2.8 KB  |  71 lines  |  [TEXT/ALFA]

  1.  points
  2.  * plus some random scaled noise. See "fractal_map.cc" for more
  3.  * details about the implementation.
  4.  *
  5.  * Usage examples:
  6.  *    IMAGE map1 = FractalMap(9);    // Use all the defaults
  7.  *    IMAGE map2 = FractalMap(9,Seeds(0,64,64,128));
  8.  *    class MyMap : public FractalMap
  9.  *    {
  10.  *      public:
  11.  *      int get_noise(const card scale) const { return your_random_number; }
  12.  *      MyMap(const card order) : FractalMap(order) {}
  13.  *    }
  14.  *    IMAGE map3 = MyMap(10);        // Play with your own random number gen
  15.  *
  16.  * One may also want to blur/sharpen the fractal map afterwards (to make
  17.  * it more appealing) by applying a corresponding filter, say, [1 1 1]
  18.  *
  19.  * Note, FractalMap is a LazyImage thing, that is, in
  20.  *    IMAGE map1 = FractalMap(9);
  21.  * map construction is done "inplace" and *no* image is copied.
  22.  *
  23.  * $Id: fractal_map.h,v 2.0 1995/03/16 17:39:58 oleg Exp oleg $
  24.  *
  25.  ************************************************************************
  26.  */
  27.  
  28. #ifndef __GNUC__
  29. #pragma once
  30. #endif
  31. #ifndef _fractal_map_h
  32. #define _fractal_map_h
  33.  
  34. #ifdef __GNUC__
  35. #pragma interface
  36. #endif
  37.  
  38. #include "image.h"
  39.  
  40. class FractalMap : public LazyImage
  41. {
  42. public:
  43.   class Seeds
  44.   {
  45.   public:
  46.     const GRAY s00, s10, s11, s01;
  47.  
  48.     Seeds(const GRAY seed) 
  49.       : s00(seed), s10(seed), s11(seed), s01(seed) {}
  50.     Seeds(const GRAY ul, const GRAY ll, const GRAY ur, const GRAY lr)
  51.       : s00(ul), s10(ll), s11(lr), s01(ur) {}
  52.   };
  53.   FractalMap(const card order, const Seeds& _seeds = Seeds(128),
  54.          const card bits_per_pixel=8);
  55.  
  56.                 // Get some noise with a dispersion 'scale'
  57.                 // (which is assumed to be a power of 2)
  58.                 // and average 0
  59.                 // Say, if scale=2 return either 0 or 1
  60.                 // if scale=128, return a random number
  61.                 // within [-64,63]
  62.   virtual int get_noise(const card scale) const;
  63. private:
  64.   Seeds seeds;
  65.   void fill_in(IMAGE& im) const;
  66. };
  67.  
  68. #endif
  69.  
  70.  
  71.